<?php

namespace Bean;

abstract class User extends \Library\Bean {

	public static function get( $userId ) {
		if( (int) $userId ) {
			$userId = 'Db:' . $userId;
		}
		$pos = strpos($userId, ':');
		$class = '\Bean\\' . substr($userId, 0, $pos) . '\User';
		return $class::get( substr($userId, $pos+1) );
	}
	
	public static function getUser( $user ) {
		$userId = $user['user_id'];
		if( (int) $userId ) {
			$userId = 'Db:' . $userId;
		}
		$pos = strpos($userId, ':');
		$class = '\Bean\\' . substr($userId, 0, $pos) . '\User';
		return $class::getUser( $user );
	}
	
	public abstract function getFullName();
	
	public abstract function getUserId();
	
	public abstract function getUrl();
	
	public function isMe() {
		return $this->is();
	}
	
	public function is( User $user = null ) {
		$user = _u($user);
		if( !$user ) {
			return false;
		}
		return $this->getUserId() == $user->getUserId();
	}
}

